package cn.itcast.bos.transit.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import cn.itcast.bos.domain.transit.DeliveryInfo;
import cn.itcast.bos.domain.transit.TransitInfo;
import cn.itcast.bos.transit.dao.DeliveryInfoDao;
import cn.itcast.bos.transit.dao.TransitInfoDao;
import cn.itcast.bos.transit.service.DeliveryInfoService;

@Service
@Transactional
public class DeliveryInfoServiceImpl implements DeliveryInfoService{
	@Autowired
	private DeliveryInfoDao deliveryInfoDao;
	@Autowired
	private TransitInfoDao transitInfoDao;
	
	@Override
	public void save(DeliveryInfo t) {
		// TODO Auto-generated method stub
		TransitInfo transitInfo = transitInfoDao.getOne(t.getId());
		if(transitInfo.getStatus().equals("到达网点")){
			t.setId(null);
			DeliveryInfo deliveryInfo = deliveryInfoDao.save(t);
			transitInfo.setDeliveryInfo(deliveryInfo);
			transitInfo.setStatus("开始配送");
		}else{
			throw new RuntimeException("商品不在网点");
		}
	
	}

}
